import junit.framework.TestCase; import junit.framework.Assert; public class MyMathCompleteTest extends TestCase { public void testAbsNegative() { // Purpose: test that abs() works for a value < 0. int testValueX; // Test data for calling method int expected; // Value we expect to see as result int actual; // Actual value that method returns // Test data for method testValueX = -4; // Expected and actual results expected = 4; actual = MyMath.abs( testValueX ); // Check if we have expected results Assert.assertEquals( expected, actual ); } public void testAbsZero() { // Purpose: test that abs() works for a value == 0. int testValueX; // Test data for calling method int expected; // Value we expect to see as result int actual; // Actual value that method returns // Test data for method testValueX = 0; // Expected and actual results expected = 0; actual = MyMath.abs( testValueX ); // Check if we have expected results Assert.assertEquals( expected, actual ); } public void testPowNormal() { // Purpose: test that pow() works for x > 1, y > 1 int testValueX; // Test data for calling method, parameter x int testValueY; // Test data for calling method, parameter y int expected; // Value we expect to see as result int actual; // Actual value that method returns // Test data for method testValueX = 2; testValueY = 7; // Expected and actual results expected = 128; actual = MyMath.pow( testValueX, testValueY ); // Check if we have expected results Assert.assertEquals( expected, actual ); } public void testPowXOne() { // Purpose: test that pow() works for x == 1, y > 1 int testValueX; // Test data for calling method, parameter x int testValueY; // Test data for calling method, parameter y int expected; // Value we expect to see as result int actual; // Actual value that method returns // Test data for method testValueX = 1; testValueY = 7; // Expected and actual results expected = 1; actual = MyMath.pow( testValueX, testValueY ); // Check if we have expected results Assert.assertEquals( expected, actual ); } public void testPowXZero() { // Purpose: test that pow() works for x == 0, y > 1 int testValueX; // Test data for calling method, parameter x int testValueY; // Test data for calling method, parameter y int expected; // Value we expect to see as result int actual; // Actual value that method returns // Test data for method testValueX = 0; testValueY = 7; // Expected and actual results expected = 0; actual = MyMath.pow( testValueX, testValueY ); // Check if we have expected results Assert.assertEquals( expected, actual ); } public void testPowXNegative() { // Purpose: test that pow() works for x < 0, y > 1 int testValueX; // Test data for calling method, parameter x int testValueY; // Test data for calling method, parameter y int expected; // Value we expect to see as result int actual; // Actual value that method returns // Test data for method testValueX = -2; testValueY = 7; // Expected and actual results expected = -128; actual = MyMath.pow( testValueX, testValueY ); // Check if we have expected results Assert.assertEquals( expected, actual ); } public void testPowYOne() { // Purpose: test that pow() works for x > 1, y == 1 int testValueX; // Test data for calling method, parameter x int testValueY; // Test data for calling method, parameter y int expected; // Value we expect to see as result int actual; // Actual value that method returns // Test data for method testValueX = 2; testValueY = 1; // Expected and actual results expected = 2; actual = MyMath.pow( testValueX, testValueY ); // Check if we have expected results Assert.assertEquals( expected, actual ); } public void testPowXOneYOne() { // Purpose: test that pow() works for x == 1, y == 1 int testValueX; // Test data for calling method, parameter x int testValueY; // Test data for calling method, parameter y int expected; // Value we expect to see as result int actual; // Actual value that method returns // Test data for method testValueX = 1; testValueY = 1; // Expected and actual results expected = 1; actual = MyMath.pow( testValueX, testValueY ); // Check if we have expected results Assert.assertEquals( expected, actual ); } public void testPowXZeroYOne() { // Purpose: test that pow() works for x == 0, y == 1 int testValueX; // Test data for calling method, parameter x int testValueY; // Test data for calling method, parameter y int expected; // Value we expect to see as result int actual; // Actual value that method returns // Test data for method testValueX = 0; testValueY = 1; // Expected and actual results expected = 0; actual = MyMath.pow( testValueX, testValueY ); // Check if we have expected results Assert.assertEquals( expected, actual ); } public void testPowXNegativeYOne() { // Purpose: test that pow() works for x < 0, y == 1 int testValueX; // Test data for calling method, parameter x int testValueY; // Test data for calling method, parameter y int expected; // Value we expect to see as result int actual; // Actual value that method returns // Test data for method testValueX = -2; testValueY = 1; // Expected and actual results expected = -2; actual = MyMath.pow( testValueX, testValueY ); // Check if we have expected results Assert.assertEquals( expected, actual ); } public void testPowYZero() { // Purpose: test that pow() works for x > 1, y == 0 int testValueX; // Test data for calling method, parameter x int testValueY; // Test data for calling method, parameter y int expected; // Value we expect to see as result int actual; // Actual value that method returns // Test data for method testValueX = 2; testValueY = 0; // Expected and actual results expected = 1; actual = MyMath.pow( testValueX, testValueY ); // Check if we have expected results Assert.assertEquals( expected, actual ); } public void testPowXOneYZero() { // Purpose: test that pow() works for x == 1, y == 0 int testValueX; // Test data for calling method, parameter x int testValueY; // Test data for calling method, parameter y int expected; // Value we expect to see as result int actual; // Actual value that method returns // Test data for method testValueX = 1; testValueY = 0; // Expected and actual results expected = 1; actual = MyMath.pow( testValueX, testValueY ); // Check if we have expected results Assert.assertEquals( expected, actual ); } public void testPowXZeroYZero() { // Purpose: test that pow() works for x == 0, y == 0 int testValueX; // Test data for calling method, parameter x int testValueY; // Test data for calling method, parameter y int expected; // Value we expect to see as result int actual; // Actual value that method returns // Test data for method testValueX = 0; testValueY = 0; // Expected and actual results expected = 1; actual = MyMath.pow( testValueX, testValueY ); // Check if we have expected results Assert.assertEquals( expected, actual ); } public void testPowXNegativeYZero() { // Purpose: test that pow() works for x < 0, y == 0 int testValueX; // Test data for calling method, parameter x int testValueY; // Test data for calling method, parameter y int expected; // Value we expect to see as result int actual; // Actual value that method returns // Test data for method testValueX = -2; testValueY = 0; // Expected and actual results expected = 1; actual = MyMath.pow( testValueX, testValueY ); // Check if we have expected results Assert.assertEquals( expected, actual ); } }